package com.wlstock.funi.dao;

import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.wlstock.funi.model.AIAccountsModel;
import com.wlstock.funi.model.BaseStockInfo;
import com.wlstock.funi.model.MyAccountStocks;
import com.wlstock.funi.model.PositionModel;
import com.wlstock.funi.model.SelfFundHisModel;
import com.wlstock.funi.model.SelfFundModel;
import com.wlstock.funi.model.SelfFundSetModel;
import com.wlstock.funi.model.StrategyFundModel;
import com.wlstock.funi.model.StrategyModel;
import com.wlstock.funi.model.TradeHisModel;

import java.sql.SQLException;

public class UpdateTableUtils {
	
	public static void updateV1(ConnectionSource connectionSource) throws SQLException{
		TableUtils.createTableIfNotExists(connectionSource, SelfFundModel.class);
	}

	public static void updateV2(ConnectionSource connectionSource) throws SQLException {
		TableUtils.createTableIfNotExists(connectionSource, BaseStockInfo.class);
	}
	
	public static void updateV3(ConnectionSource connectionSource) throws SQLException {
		TableUtils.createTableIfNotExists(connectionSource, SelfFundSetModel.class);
	}

	public static void updateV4(ConnectionSource connectionSource) throws SQLException {
		TableUtils.createTableIfNotExists(connectionSource, AIAccountsModel.class);
		TableUtils.createTableIfNotExists(connectionSource, TradeHisModel.class);
	}

	public static void updateV5(ConnectionSource connectionSource) throws SQLException {
		TableUtils.createTableIfNotExists(connectionSource, PositionModel.class);
	}

	public static void updateV6(ConnectionSource connectionSource) throws SQLException {
		TableUtils.createTableIfNotExists(connectionSource, StrategyFundModel.class);
	}

	public static void updateV7(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);
	}

	public static void updateV8(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, SelfFundSetModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundSetModel.class);
	}

	public static void updateV9(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyFundModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyFundModel.class);
	}

	public static void updateV10(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyFundModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyFundModel.class);
	}

	public static void updateV11(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyModel.class);

		TableUtils.dropTable(connectionSource, StrategyFundModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyFundModel.class);
	}

	public static void  updateV12(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);
	}

	public static void  updateV13(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);
	}

	public static void  updateV14(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyModel.class);
	}

	public static void  updateV15(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyModel.class);
	}

	public static void  updateV16(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);
	}

	public static void  updateV17(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, StrategyModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyModel.class);
		TableUtils.dropTable(connectionSource, StrategyFundModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, StrategyFundModel.class);
	}

	public static void  updateV18(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);

		TableUtils.dropTable(connectionSource, PositionModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, PositionModel.class);
	}

	public static void  updateV19(ConnectionSource connectionSource) throws SQLException {
		TableUtils.dropTable(connectionSource, PositionModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, PositionModel.class);
	}

	public static void  updateV20(ConnectionSource connectionSource) throws SQLException{
		TableUtils.dropTable(connectionSource, MyAccountStocks.class,true);
		TableUtils.createTableIfNotExists(connectionSource, MyAccountStocks.class);
	}

	public static void  updateV21(ConnectionSource connectionSource) throws SQLException{
		TableUtils.dropTable(connectionSource, SelfFundModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundModel.class);
	}

	public static void updateV22(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.createTableIfNotExists(connectionSource, SelfFundHisModel.class);
	}

	public static void updateV23(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.dropTable(connectionSource, SelfFundHisModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundHisModel.class);
	}

	public static void updateV24(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.dropTable(connectionSource, SelfFundHisModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundHisModel.class);
	}

	public static void updateV25(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.dropTable(connectionSource, SelfFundHisModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundHisModel.class);
	}

	public static void updateV26(ConnectionSource connectionSource) throws  SQLException{
		TableUtils.dropTable(connectionSource, SelfFundHisModel.class,true);
		TableUtils.createTableIfNotExists(connectionSource, SelfFundHisModel.class);
	}

}
